﻿define(function (require) {
    var WorkitemView = require('views/workitem.view');

    return Backbone.View.extend({
        tagName: "ul",
        events: {

        },

        initialize: function () {
            $(this.el).addClass('workitem-list ui-listview ui-listview-inset ui-corner-all ui-shadow')
                      .attr({
                          "data-role": "listview",
                          "data-split-theme": "d",
                          "data-inset": "true"
                      });

            _.bindAll(this, 'addOne', 'render');
            this.model.bind('getAll', this.render);
            this.model.getAll();
        },
        render: function () {
            this.model.each(this.addOne);
            return this;
        },
        addOne: function (e) {
            var view = new WorkitemView({ model: e });
            var element = view.render().el;
            $(this.el).append(element);
        },

        clear: function (e) {

        }

    });

});